package org.locker.domain.enums;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.locker.common.core.exception.ServiceException;

/**
 * 订单类型
 *
 * @author locker
 */
@Getter
@AllArgsConstructor
public enum SpecCodeEnum   {

    small("small", "小柜"),
    common("common", "中柜"),
    large("large", "大柜"),
    ;

    @EnumValue
    private final String code;
    private final String desc;

    public static String getCodeByDesc(String desc) {
        for (SpecCodeEnum specCodeEnum : SpecCodeEnum.values()) {
            if (specCodeEnum.desc.equals(desc)) {
                return specCodeEnum.code;
            }
        }
        throw new ServiceException(StrUtil.format("{} 规格错误! 系统柜子规格有 {},{},{}",desc,small.getDesc(),common.getDesc(),large.getDesc()));
    }

}
